结构是打算做成这样:所有的界面都有一个根节点,显示Panel的时候如果是modal就创建一个modal背景在panel的后面。
所以modal的父级和panel的父级一样,现在是panel通过prefab加载创建出来正常显示。modal不显示。
show的代码是这样:
async show(container?: Node, modal?: boolean) {
await this.load();
if (container) {
this._container = container;
}
if (!this._container) {
this._container = UILayer.inst.getPanelLayer();
}
this._container.on(Node.EventType.SIZE_CHANGED, this.onParentSizeChange, this);
if (modal) {
if (!this._modalNode) {
this._modalNode = this.createModal();
} else {
this._modalNode.active = true;
}
this._container.addChild(this._modalNode);
}
this.doShow();
const t = this.getShowTween();
t && t.start();
}
|